#include"fraction.h"
#include<iostream>
using namespace std;

int Fraction::chkvalid(void)
{
	
	if (denom==0)
		return 0;
	else return 1;
	
}


Fraction::Fraction(int a,int b)
{
	numer=a;
	denom=b;
	
	if(!chkvalid())
	{
		cout<<"invalid fraction entered";
		cout<<"  aplying default values";
		numer=1;
		denom=1;
	}
	
	
}
void Fraction::display(void)
{
	cout<<"\n value of numerator is  "<<numer;
	cout<<"\n values of denominator is "<<denom;
	
}

void Fraction::reduce(void)
{
	int i,small,a,b;
	a=numer;
	b=denom;
	small = (a<b) ? a :b;
	for(i=small;i>0;i--)	
	{
		if((numer%i==0)&&(denom%i==0))
		{
			numer/=i;
			denom/=i;
			break;
		}
		
	}
	
}	



